/**
 * Author: Lily Jiang
 * Create Time: 2019/12/24
 * Description:
 */

import React from "react";
import './Index.scss'
import {Link} from 'react-router-dom'
import PropTypes from 'prop-types';

class CompArticleItem extends React.PureComponent {
    constructor(props) {
        super(props);
        this.state = {

        };
    }


    render() {
        return (
            <Link to={'/article/detail?articleId=' + this.props.info.id} className="comp_article-item-wrap">
                <div className="df1 pr10">
                    <div className={'article-title line-clamp2'}>{this.props.info.picture_title || this.props.info.title || ''}</div>
                    {
                        this.props.showAuthor && (<div className="article-author">{this.props.info.user.username}</div>)
                    }

                </div>
                <div className="img" style={{backgroundImage: `url(${this.props.info.picture})`}}></div>
            </Link>
        );
    }
}

CompArticleItem.defaultProps = {
    showAuthor: true,
    info: {
        // user: {}
    }
};

CompArticleItem.propTypes = {
    showAuthor: PropTypes.bool,
    info: PropTypes.object,
};

export default CompArticleItem